package custom.base.entity.base;

import java.io.Serializable;

/**
 * Created by luozi on 2015/12/31.
 */
public class  BaseResponse<T> implements Serializable {
    /**
     * 请求响应码
     */
    int code;
    /**
     * 请求响应文本
     */
    String msg;
    String exception;

    int page = 0;
    int totalElements = 0;
    int totalPage = 0;
    /**
     * 响应实体类
     */
    T data;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public BaseResponse setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public String getException() {
        return exception;
    }

    public void setException(String exception) {
        this.exception = exception;
    }

    @SuppressWarnings({"unchecked", "UnusedDeclaration"})
    public T getData() {
        return data;
    }

    public BaseResponse setData(T data) {
        this.data = data;
        return this;
    }

    @Override
    public String toString() {
        return "BaseResponse{" +
                "code=" + code +
                ", '" + (msg == null ? "msg为空" : "msg=" + msg) + '\'' +
                ", '" + (exception == null ? "exception为空" : "exception=" + exception) + '\'' +
                ", " + (data == null ? "data为空" : "data=" + data.toString()) +
                '}';
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getTotalElements() {
        return totalElements;
    }

    public void setTotalElements(int totalElements) {
        this.totalElements = totalElements;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }
}
